from itertools import count

def digits(n):
    return frozenset(str(n))

for n in count(1):
    if all(digits(n) == digits(i * n) for i in xrange(2,7)):
           print n
           break
